import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WarehouseStockRealTimeVO, WarehouseStockRealTimeForm, WarehouseStockRealTimeQuery } from '@/api/lingxing/warehouseStockRealTime/types';

/**
 * 查询领星仓库即时库存列表
 * @param query
 * @returns {*}
 */

export const listWarehouseStockRealTime = (query?: WarehouseStockRealTimeQuery): AxiosPromise<WarehouseStockRealTimeVO[]> => {
  return request({
    url: '/lingxing/warehouseStockRealTime/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询领星仓库即时库存详细
 * @param id
 */
export const getWarehouseStockRealTime = (id: string | number): AxiosPromise<WarehouseStockRealTimeVO> => {
  return request({
    url: '/lingxing/warehouseStockRealTime/' + id,
    method: 'get'
  });
};

/**
 * 新增领星仓库即时库存
 * @param data
 */
export const addWarehouseStockRealTime = (data: WarehouseStockRealTimeForm) => {
  return request({
    url: '/lingxing/warehouseStockRealTime',
    method: 'post',
    data: data
  });
};

/**
 * 修改领星仓库即时库存
 * @param data
 */
export const updateWarehouseStockRealTime = (data: WarehouseStockRealTimeForm) => {
  return request({
    url: '/lingxing/warehouseStockRealTime',
    method: 'put',
    data: data
  });
};

/**
 * 删除领星仓库即时库存
 * @param id
 */
export const delWarehouseStockRealTime = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lingxing/warehouseStockRealTime/' + id,
    method: 'delete'
  });
};

/**
 *
 * @returns {*}
 */
export const syncData = () => {
  return request({
    url: '/lingxing/warehouseStockRealTime/syncData',
    method: 'post'
  });
};

export const getNewestUpdateTime = () => {
  return request({
    url: '/lingxing/warehouseStockRealTime/getNewestUpdateTime',
    method: 'get'
  });
};
